//
//  JAGAdConst.h
//  JAGatherAdDemo
//
//  Created by Yc on 2022/11/15.
//

#ifndef JAGAdConst_h
#define JAGAdConst_h

#define JAG_ScreenW    [UIScreen mainScreen].bounds.size.width
#define JAG_ScreenH    [UIScreen mainScreen].bounds.size.height

//状态栏高度  全面屏状态栏高度为44pt，非全面屏状态栏高度为20pt
#define kStatusBarHeight [UIApplication sharedApplication].statusBarFrame.size.height

#define JAG_NavigationHeight (kStatusBarHeight == 20 ? 64:88)

#define JAG_FULLSCREEN (kStatusBarHeight == 20?NO:YES)

#define JAG_WS(ws) __weak typeof(self)ws = self;
// 强弱引用
#define JAGWeakSelf    __weak typeof(self) ws = self;
#define JAGStrongSelf  __strong typeof(ws) self = ws;

#define JAGIsEmptyString(str) ([str isKindOfClass:[NSNull class]] || str == nil || [[str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] < 1  || [str isEqualToString:@"<null>"] || [str isEqualToString:@"(null)"]? YES : NO )

//color
#define JAGColorFromHex(hexValue,a) [UIColor \
colorWithRed:((float)((hexValue & 0xFF0000) >> 16))/255.0 \
green:((float)((hexValue & 0xFF00) >> 8))/255.0 \
blue:((float)(hexValue & 0xFF))/255.0 alpha:a]

#define ISVideoTypeWithPath(path)\
({\
BOOL result = NO;\
if([path hasSuffix:@".mp4"])  result =  YES;\
(result);\
})

#define DataWithFileName(name)\
({\
NSData *data = nil;\
NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:nil];\
if([[NSFileManager defaultManager] fileExistsAtPath:path]){\
    data = [NSData dataWithContentsOfFile:path];\
}\
(data);\
})


#define DISPATCH_SOURCE_CANCEL_SAFE(time) if(time)\
{\
dispatch_source_cancel(time);\
time = nil;\
}

#define REMOVE_FROM_SUPERVIEW_SAFE(view) if(view)\
{\
[view removeFromSuperview];\
view = nil;\
}

#define JAGCacheImageUrlStringKey    @"JAGCacheImageUrlStringKey"
#define JAGCacheVideoUrlStringKey    @"JAGCacheVideoUrlStringKey"

#endif /* JAGAdConst_h */
